#include "Sheet.h"
#include <iostream>
#include <iomanip>
#pragma comment(lib, "Sheet.lib")

void PrintEntry(Entry* e)
{		
	Sheet* s = e->GetSheet();
	int c = s->GetColumnCount();
	for(int i =0; i != c; i++)
	{
		Cell* cell = e->GetCell(i);
		int type = s->GetType(i);
		switch(type)
		{
		case CT_ID:
		case CT_INT:
			std::cout<<std::setw(10)<<cell->toInt();
			break;
		case CT_FLOAT:
			std::cout<<std::setw(10)<<cell->toFloat();
			break;
		case CT_STR:
			std::cout<<std::setw(10)<<cell->toStr();
			break;
		}
	}
	std::cout <<std::endl;
}
void main()
{
	Sheet* s = LoadSheet("..\\res\\sheet.txt");
	if(s)
	{
		int c = s->GetColumnCount();
		for(int i =0; i != c; i++)
		{
			std::cout <<std::setw(10) <<s->GetTitle(i);
		}
		std::cout <<std::endl;
		EntryIter* eb = s->GetFirst();
		EntryIter* ee = s->GetLast();

		while(*eb != *ee)
		{
			Entry* entry = eb->GetEntry();

			PrintEntry(entry);
			eb->Next();
		}

		delete s;
	}

}